/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.manage.controller;

import info.peigen.hotpot.business.customer.manage.form.PartnerManageCreateForm;
import info.peigen.hotpot.business.customer.manage.form.PartnerManageEditForm;
import info.peigen.hotpot.business.customer.manage.form.PartnerManageSearchForm;
import info.peigen.hotpot.business.customer.manage.info.PartnerManageInfo;
import info.peigen.hotpot.business.customer.manage.service.PartnerManageService;
import info.peigen.hotpot.common.core.result.PageResult;
import info.peigen.hotpot.common.core.result.manage.WebResult;
import info.peigen.hotpot.component.data.repository.beetlsql.filter.ManageDataAspect;
import org.noear.solon.annotation.Body;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.validation.annotation.Valid;

/**
 * <b>(PartnerManageController)</b>
 * 管理后台 "合作伙伴"控制器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-09-09
 */
@SuppressWarnings({"rawtypes", "unchecked", "unused"})
@Valid
@Controller
@Mapping("partner")
public class PartnerManageController {
    @Inject
    PartnerManageService partnerManageService;

    @Mapping("page")
    @ManageDataAspect
    WebResult page(@Body PartnerManageSearchForm form) {
        PageResult<PartnerManageInfo> page = partnerManageService.page(form);
        return WebResult.setSuccessResult().setInfo(page);
    }

    @Mapping("create")
    @ManageDataAspect
    WebResult create(@Body PartnerManageCreateForm form) {
        partnerManageService.create(form);
        return WebResult.setSuccessResult();
    }

    @Mapping("edit")
    @ManageDataAspect
    WebResult edit(@Body PartnerManageEditForm form) {
        partnerManageService.edit(form);
        return WebResult.setSuccessResult();
    }

    @Mapping("remove")
    @ManageDataAspect
    WebResult remove(@Body PartnerManageSearchForm form) {
        partnerManageService.remove(form.getId());
        return WebResult.setSuccessResult();
    }
}
